package org.springframework.boot.autoconfigure.mock.test;

import org.springframework.boot.autoconfigure.mock.annotation.MockResponse;
import org.springframework.boot.autoconfigure.mock.model.MockResTypeEnum;
import org.springframework.stereotype.Service;

@Service
public class MockResService {

    @MockResponse(require = true, value = "{'name': 'mock', 'age': 20, 'addr': '广东省深圳市'}", mockResTypeEnum = MockResTypeEnum.JSON)
    public User getUserFromJson(String name, Integer age) {
        final User user = new User();
        user.setName(name);
        user.setAge(age);
        return user;
    }

    @MockResponse(require = true, value = "spring.mock.response.user", mockResTypeEnum = MockResTypeEnum.PROP)
    public User getUserFromProp(String name, Integer age) {
        final User user = new User();
        user.setName(name);
        user.setAge(age);
        return user;
    }

    @MockResponse(require = true, clazz = MockPrepareService.class, method = "buildMockUser", mockResTypeEnum = MockResTypeEnum.METHOD)
    public User getUserFromMethod(String name, Integer age) {
        final User user = new User();
        user.setName(name);
        user.setAge(age);
        return user;
    }
}
